package utils

import (
	"bytes"
	"encoding/binary"

	"github.com/pborman/uuid"
)

const (
	max = 9223372036854775807
	min = 1000000000000000000
)

func NewGUID() int64 {
	var guid int64
	for {
		if err := binary.Read(bytes.NewReader(uuid.NewRandom()), binary.BigEndian, &guid); err != nil {
			panic(err)
		}
		if guid > min {
			return guid
		}
	}
}

func NewRandom() string {
	return uuid.New()
}

func NewRandomBytes() []byte {
	return uuid.NewRandom()
}
